package com.sfc.web.controller;

import com.sfc.dto.UserDTO;
import com.sfc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by heylear.cai on 2016/3/11.
 */
//@Controller
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;

    @RequestMapping("/register")
    public Long register(UserDTO user){
        return userService.saveUser(user);
    }

    @RequestMapping("/login")
    public UserDTO login(UserDTO user){
        return userService.getUserByUsernameAndPasswd(user.getUsername(), user.getPasswd());
    }

}
